package com.nebula.util;

/**
 * @author CcccX
 * @create 2019-01-08 16:15
 */
public class NamedUtil {
    public static final char UNDERLINE = '_';
    public static String camelToUnderline(String param){
        if (param == null || "".equals(param.trim())){
            return "";
        }
        int len = param.trim().length();
        StringBuilder sb = new StringBuilder(len);
        for (int i = 0;i < len; i++){
            char c = param.trim().charAt(i);
            if (Character.isUpperCase(c)){
                sb.append(UNDERLINE);
                sb.append(Character.toLowerCase(c));
            }else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}
